@basicbenframework/cms 0.0.0-stage → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ling Chi Tao (@ctmakes)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,207 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BasicBen CMS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Posts, pages, categories, tags, media, comments, an admin UI, and a headless
|
|
4
|
+
content API at `/api/v1`. Built on [BasicBen](https://github.com/BasicBenFramework/core).
|
|
5
|
+
|
|
6
|
+
The CMS is a package, `@basicbenframework/cms`. A site installs it and keeps
|
|
7
|
+
only its own configuration and deploy files:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @basicbenframework/create my-site # --headless for no public theme
|
|
11
|
+
cd my-site && npm install && npm run migrate && npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Updating a site is `npm install @basicbenframework/cms@latest` and
|
|
15
|
+
`npm run migrate`. What a site holds is in [site/README.md](site/README.md).
|
|
16
|
+
|
|
17
|
+
## This repository
|
|
18
|
+
|
|
19
|
+
The package's source is `src/`, compiled to `lib/` (`npm run build:lib`), with
|
|
20
|
+
its migrations in `db/migrations/` and mail templates in `mail/`. `site/` is
|
|
21
|
+
the template `create` copies, and an npm workspace that installs the package
|
|
22
|
+
from this checkout, so working on the CMS has no publish step:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
cp site/.env.example site/.env # then set APP_KEY
|
|
27
|
+
npm run migrate
|
|
28
|
+
npm run dev # admin on http://localhost:3000, API on :3001
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`npm run dev` rebuilds `lib/` as you edit and the site picks it up. The first
|
|
32
|
+
account you register becomes the admin. Without a `RESEND_API_KEY` mail is
|
|
33
|
+
printed to the terminal rather than sent, including the verification link.
|
|
34
|
+
|
|
35
|
+
To change the CMS for one site rather than for everyone, fork this repository.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run dev # Development, the template site against src/
|
|
41
|
+
npm run build # lib/, then a production build of site/
|
|
42
|
+
npm start # Production server (site/)
|
|
43
|
+
npm test # Tests, run from site/ as a site runs
|
|
44
|
+
./scripts/smoke-test.sh # Pack, install into a copy of site/, build, boot, check
|
|
45
|
+
npm run migrate # Apply pending migrations
|
|
46
|
+
npm run migrate:status # What has and has not run
|
|
47
|
+
npm run migrate:rollback # Undo the last batch
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Databases
|
|
51
|
+
|
|
52
|
+
SQLite by default, with no configuration. Postgres and Turso are selected from
|
|
53
|
+
the environment rather than named in config — a `postgres://` `DATABASE_URL`
|
|
54
|
+
picks Postgres, a `TURSO_URL` picks Turso.
|
|
55
|
+
|
|
56
|
+
Each migration runs in a transaction together with the row recording that it
|
|
57
|
+
ran, so a failure leaves the schema untouched rather than half-applied. Two
|
|
58
|
+
limits are documented rather than worked around, neither reachable from the
|
|
59
|
+
migrations shipped here: Postgres refuses `CREATE INDEX CONCURRENTLY` and
|
|
60
|
+
`VACUUM` inside a transaction, and SQLite ignores `PRAGMA foreign_keys` there.
|
|
61
|
+
|
|
62
|
+
## The headless API
|
|
63
|
+
|
|
64
|
+
`/api/v1/{posts,pages,authors,categories,tags,media}`, read-only, authenticated
|
|
65
|
+
with a scoped `bb_` token or served anonymously if you turn on public reads.
|
|
66
|
+
Posts filter by `?category=`, `?tag=` and `?author=`, each taking a slug or an
|
|
67
|
+
id, so an author archive is one request. The
|
|
68
|
+
response shapes are documented at `/docs/headless` in the running app, and that
|
|
69
|
+
page is **generated** from the interfaces in `src/models/PublicContent.ts` — so
|
|
70
|
+
the field list cannot drift from the code. Re-run it after changing a shape:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node scripts/generate-api-reference.js
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A test fails when the checked-in output stops matching.
|
|
77
|
+
|
|
78
|
+
### Rate limits shape how consumers should read
|
|
79
|
+
|
|
80
|
+
`/api/v1` allows 120 requests a minute per address, keyed on the address rather
|
|
81
|
+
than the token because the limiter has to run before authentication — otherwise
|
|
82
|
+
a flood of fabricated tokens is never limited.
|
|
83
|
+
|
|
84
|
+
That budget assumes consumers fetch *collections*. A static site generator that
|
|
85
|
+
fetches one post per slug makes one request per post and will cross the ceiling
|
|
86
|
+
somewhere past a hundred posts. Fetch pages of 100 and slice locally: a whole
|
|
87
|
+
site becomes a handful of requests.
|
|
88
|
+
|
|
89
|
+
## Authors
|
|
90
|
+
|
|
91
|
+
Every account is an author profile: a display name, a biography, a link, an
|
|
92
|
+
avatar, and a slug that addresses them at `?author=`. People edit their own at
|
|
93
|
+
`/profile`; the avatar goes through the same upload the media library uses, so
|
|
94
|
+
it is an ordinary media row.
|
|
95
|
+
|
|
96
|
+
A post is attributed to whoever wrote it. Reassigning one to somebody else needs
|
|
97
|
+
`post.edit` — the capability an editor and an admin hold and an author does not,
|
|
98
|
+
which is the WordPress rule: you write under your own name, and an editor may
|
|
99
|
+
hand a post to another writer. The editor's Author menu appears only for
|
|
100
|
+
accounts that hold it.
|
|
101
|
+
|
|
102
|
+
`author` on a post in the content API is still the display name it always was.
|
|
103
|
+
The profile arrives beside it as `author_profile`, so a static build renders a
|
|
104
|
+
byline with a face and a biography without a request per post.
|
|
105
|
+
|
|
106
|
+
## Slugs, excerpts and featured images
|
|
107
|
+
|
|
108
|
+
Leave the slug or the excerpt blank and the server writes one — the slug from
|
|
109
|
+
the title, numbered if it is taken, the excerpt from the content. Both are
|
|
110
|
+
derived once, on write: a slug computed per request is not a permalink, and
|
|
111
|
+
would follow the title around, breaking every link to the post the first time
|
|
112
|
+
someone fixed a typo in a headline. Clearing either field asks for a fresh one;
|
|
113
|
+
a request that does not mention them leaves what is there.
|
|
114
|
+
|
|
115
|
+
Posts and pages both carry a featured image. It is stored as a media id and
|
|
116
|
+
resolved through the storage adapter on read, so moving buckets or putting a CDN
|
|
117
|
+
in front of one does not mean rewriting rows.
|
|
118
|
+
|
|
119
|
+
## Migrating from WordPress
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npx basicben-cms import:wordpress --dry-run
|
|
123
|
+
npx basicben-cms import:wordpress
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Posts are matched on slug, so it is safe to run repeatedly — import now, keep
|
|
127
|
+
publishing on WordPress, re-run with `--update` immediately before cutting
|
|
128
|
+
over (without it, posts that already exist are left alone).
|
|
129
|
+
|
|
130
|
+
It brings across posts, pages, comments and authors. Authors become accounts
|
|
131
|
+
with the Author role and no password; they sign in with "forgot password"
|
|
132
|
+
(`--no-authors` attributes everything to the first admin instead). For an offline WordPress export file, a Ghost export, or moving
|
|
133
|
+
this CMS between databases, see [docs/import-export.md](docs/import-export.md):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run import:wxr -- wordpress.xml --dry-run
|
|
137
|
+
npm run import:ghost -- ghost.json --url https://old.example.com --dry-run
|
|
138
|
+
npm run export -- --out site.json # or Admin → Tools → Export
|
|
139
|
+
npm run import:json -- site.json --dry-run
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
It does not re-upload media. A featured image is recorded as the object key it
|
|
143
|
+
already has and served through `publicUrl`, so images resolve when storage
|
|
144
|
+
points at the host already serving them. If your WordPress media sits on the
|
|
145
|
+
WordPress host rather than object storage, move the files first.
|
|
146
|
+
|
|
147
|
+
Categories are many-to-many here, so a post keeps every one it had; the first
|
|
148
|
+
is recorded as its primary category, which is what a breadcrumb or a canonical
|
|
149
|
+
URL names.
|
|
150
|
+
|
|
151
|
+
## Deploying
|
|
152
|
+
|
|
153
|
+
`npm start` runs this on any persistent host with nothing to configure.
|
|
154
|
+
|
|
155
|
+
### Vercel
|
|
156
|
+
|
|
157
|
+
`vercel.json` and `api/index.js` are the whole of it. BasicBen is a long-running
|
|
158
|
+
`node:http` server and Vercel invokes a handler per request, so the handler
|
|
159
|
+
bridges them: `app.server` is a real `http.Server`, and that class dispatches by
|
|
160
|
+
emitting `request` — handing it Vercel's `req`/`res` runs the identical
|
|
161
|
+
middleware chain, router and error handler. Nothing is re-implemented, and local
|
|
162
|
+
and production execute the same code. `src/server/index.ts` skips its own
|
|
163
|
+
`listen()` when `VERCEL` is set.
|
|
164
|
+
|
|
165
|
+
Two things that catch people out:
|
|
166
|
+
|
|
167
|
+
- **`/feed.xml`, `/feed.json` and `/sitemap.xml` are server-rendered** and live
|
|
168
|
+
outside `/api`. A rewrite covering only `/api/*` 404s all three, and the admin
|
|
169
|
+
UI still looks fine, so it is easy to miss.
|
|
170
|
+
- **Object storage stops being optional.** The filesystem is read-only apart
|
|
171
|
+
from an ephemeral `/tmp`, so the local driver cannot accept uploads at all.
|
|
172
|
+
The app warns at boot when it detects that combination. Reads are unaffected.
|
|
173
|
+
|
|
174
|
+
Set `APP_KEY`, `APP_URL`, your database variables and the `S3_*` group in the
|
|
175
|
+
project's environment. Run migrations from your machine or CI — they do not run
|
|
176
|
+
on a serverless host.
|
|
177
|
+
|
|
178
|
+
The framework declares `engines.node >= 24`; confirm the platform offers it.
|
|
179
|
+
|
|
180
|
+
## Layout
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
src/ the package, compiled to lib/
|
|
184
|
+
├── config.ts defineSite (./config)
|
|
185
|
+
├── vite.ts the cms() preset (./vite)
|
|
186
|
+
├── server/index.ts the server (./server)
|
|
187
|
+
├── main.tsx the admin (./admin)
|
|
188
|
+
├── features/ analytics, members, mysendbox, theme
|
|
189
|
+
├── routes/api/v1.ts the public content API
|
|
190
|
+
├── models/PublicContent.ts what /api/v1 returns, and the reference's source
|
|
191
|
+
├── controllers/ business logic
|
|
192
|
+
├── middleware/ scopes, caching, rate limits
|
|
193
|
+
├── cli/ the basicben-cms commands
|
|
194
|
+
└── client/ admin UI and docs pages
|
|
195
|
+
db/migrations/ schema, applied in order, shipped with the package
|
|
196
|
+
mail/ mail templates, shipped with the package
|
|
197
|
+
site/ the template create copies, and the dev workspace
|
|
198
|
+
tests/ hook coverage, API reference drift
|
|
199
|
+
scripts/ the generator, the smoke test, the release
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The scaffolder, `@basicbenframework/create`, is published from the framework's
|
|
203
|
+
repository and copies `site/` at the tag of the latest published CMS.
|
|
204
|
+
|
|
205
|
+
The framework is [@basicbenframework/core](https://github.com/BasicBenFramework/core),
|
|
206
|
+
installed from npm. It used to live here; it has its own repository, and this
|
|
207
|
+
depends on it like any consumer does.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE users (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
name TEXT NOT NULL,
|
|
6
|
+
email TEXT UNIQUE NOT NULL,
|
|
7
|
+
password TEXT NOT NULL,
|
|
8
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
9
|
+
)
|
|
10
|
+
`)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const down = async (db, grammar) => {
|
|
14
|
+
await db.exec(grammar.dropTable('users'))
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE posts (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
user_id INTEGER NOT NULL,
|
|
6
|
+
title TEXT NOT NULL,
|
|
7
|
+
content TEXT NOT NULL,
|
|
8
|
+
published INTEGER NOT NULL DEFAULT 0,
|
|
9
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
11
|
+
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
12
|
+
)
|
|
13
|
+
`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const down = async (db, grammar) => {
|
|
17
|
+
await db.exec(grammar.dropTable('posts'))
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE categories (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
name TEXT NOT NULL,
|
|
6
|
+
slug TEXT UNIQUE NOT NULL,
|
|
7
|
+
description TEXT,
|
|
8
|
+
parent_id INTEGER REFERENCES categories(id) ON DELETE SET NULL,
|
|
9
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
10
|
+
)
|
|
11
|
+
`)
|
|
12
|
+
|
|
13
|
+
await db.exec('CREATE INDEX idx_categories_slug ON categories(slug)')
|
|
14
|
+
await db.exec('CREATE INDEX idx_categories_parent ON categories(parent_id)')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const down = async (db, grammar) => {
|
|
18
|
+
await db.exec(grammar.dropTable('categories'))
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE tags (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
name TEXT NOT NULL,
|
|
6
|
+
slug TEXT UNIQUE NOT NULL,
|
|
7
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
8
|
+
)
|
|
9
|
+
`)
|
|
10
|
+
|
|
11
|
+
await db.exec('CREATE INDEX idx_tags_slug ON tags(slug)')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const down = async (db, grammar) => {
|
|
15
|
+
await db.exec(grammar.dropTable('tags'))
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const up = async (db) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE post_tags (
|
|
4
|
+
post_id INTEGER NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
|
5
|
+
tag_id INTEGER NOT NULL REFERENCES tags(id) ON DELETE CASCADE,
|
|
6
|
+
PRIMARY KEY (post_id, tag_id)
|
|
7
|
+
)
|
|
8
|
+
`)
|
|
9
|
+
|
|
10
|
+
await db.exec('CREATE INDEX idx_post_tags_post ON post_tags(post_id)')
|
|
11
|
+
await db.exec('CREATE INDEX idx_post_tags_tag ON post_tags(tag_id)')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const down = async (db, grammar) => {
|
|
15
|
+
await db.exec(grammar.dropTable('post_tags'))
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE pages (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
title TEXT NOT NULL,
|
|
6
|
+
slug TEXT UNIQUE NOT NULL,
|
|
7
|
+
content TEXT,
|
|
8
|
+
template TEXT DEFAULT 'default',
|
|
9
|
+
published INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
parent_id INTEGER REFERENCES pages(id) ON DELETE SET NULL,
|
|
11
|
+
menu_order INTEGER DEFAULT 0,
|
|
12
|
+
meta_title TEXT,
|
|
13
|
+
meta_description TEXT,
|
|
14
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
16
|
+
)
|
|
17
|
+
`)
|
|
18
|
+
|
|
19
|
+
await db.exec('CREATE INDEX idx_pages_slug ON pages(slug)')
|
|
20
|
+
await db.exec('CREATE INDEX idx_pages_parent ON pages(parent_id)')
|
|
21
|
+
await db.exec('CREATE INDEX idx_pages_published ON pages(published)')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const down = async (db, grammar) => {
|
|
25
|
+
await db.exec(grammar.dropTable('pages'))
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE comments (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
post_id INTEGER NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
|
6
|
+
user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
|
|
7
|
+
parent_id INTEGER REFERENCES comments(id) ON DELETE CASCADE,
|
|
8
|
+
author_name TEXT,
|
|
9
|
+
author_email TEXT,
|
|
10
|
+
content TEXT NOT NULL,
|
|
11
|
+
approved INTEGER NOT NULL DEFAULT 0,
|
|
12
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
13
|
+
)
|
|
14
|
+
`)
|
|
15
|
+
|
|
16
|
+
await db.exec('CREATE INDEX idx_comments_post ON comments(post_id)')
|
|
17
|
+
await db.exec('CREATE INDEX idx_comments_user ON comments(user_id)')
|
|
18
|
+
await db.exec('CREATE INDEX idx_comments_parent ON comments(parent_id)')
|
|
19
|
+
await db.exec('CREATE INDEX idx_comments_approved ON comments(approved)')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const down = async (db, grammar) => {
|
|
23
|
+
await db.exec(grammar.dropTable('comments'))
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE media (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
|
|
6
|
+
filename TEXT NOT NULL,
|
|
7
|
+
original_name TEXT NOT NULL,
|
|
8
|
+
path TEXT NOT NULL,
|
|
9
|
+
mime_type TEXT,
|
|
10
|
+
size INTEGER,
|
|
11
|
+
alt_text TEXT,
|
|
12
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
13
|
+
)
|
|
14
|
+
`)
|
|
15
|
+
|
|
16
|
+
await db.exec('CREATE INDEX idx_media_user ON media(user_id)')
|
|
17
|
+
await db.exec('CREATE INDEX idx_media_mime ON media(mime_type)')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const down = async (db, grammar) => {
|
|
21
|
+
await db.exec(grammar.dropTable('media'))
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
// Add new columns to posts table for blogging features
|
|
3
|
+
await db.exec('ALTER TABLE posts ADD COLUMN slug TEXT')
|
|
4
|
+
await db.exec('ALTER TABLE posts ADD COLUMN excerpt TEXT')
|
|
5
|
+
await db.exec('ALTER TABLE posts ADD COLUMN featured_image INTEGER REFERENCES media(id)')
|
|
6
|
+
await db.exec('ALTER TABLE posts ADD COLUMN category_id INTEGER REFERENCES categories(id)')
|
|
7
|
+
await db.exec('ALTER TABLE posts ADD COLUMN meta_title TEXT')
|
|
8
|
+
await db.exec('ALTER TABLE posts ADD COLUMN meta_description TEXT')
|
|
9
|
+
await db.exec(`ALTER TABLE posts ADD COLUMN publish_at ${grammar.timestampType()}`)
|
|
10
|
+
|
|
11
|
+
// Create indexes for new columns
|
|
12
|
+
await db.exec('CREATE UNIQUE INDEX idx_posts_slug ON posts(slug)')
|
|
13
|
+
await db.exec('CREATE INDEX idx_posts_category ON posts(category_id)')
|
|
14
|
+
await db.exec('CREATE INDEX idx_posts_featured_image ON posts(featured_image)')
|
|
15
|
+
await db.exec('CREATE INDEX idx_posts_published ON posts(published)')
|
|
16
|
+
await db.exec('CREATE INDEX idx_posts_publish_at ON posts(publish_at)')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const down = async (db) => {
|
|
20
|
+
// SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
|
|
21
|
+
// For simplicity in rollback, we'll just drop the indexes
|
|
22
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_slug')
|
|
23
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_category')
|
|
24
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_featured_image')
|
|
25
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_published')
|
|
26
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_publish_at')
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const up = async (db, grammar) => {
|
|
2
|
+
await db.exec(`
|
|
3
|
+
CREATE TABLE settings (
|
|
4
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
5
|
+
key TEXT UNIQUE NOT NULL,
|
|
6
|
+
value TEXT,
|
|
7
|
+
group_name TEXT DEFAULT 'general',
|
|
8
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
10
|
+
)
|
|
11
|
+
`)
|
|
12
|
+
|
|
13
|
+
await db.exec('CREATE INDEX idx_settings_key ON settings(key)')
|
|
14
|
+
await db.exec('CREATE INDEX idx_settings_group ON settings(group_name)')
|
|
15
|
+
|
|
16
|
+
// Insert default settings
|
|
17
|
+
await db.run(`
|
|
18
|
+
INSERT INTO settings (key, value, group_name) VALUES
|
|
19
|
+
('site_name', 'My BasicBen Blog', 'general'),
|
|
20
|
+
('site_description', 'A blog powered by BasicBen', 'general'),
|
|
21
|
+
('posts_per_page', '10', 'reading'),
|
|
22
|
+
('allow_comments', 'true', 'discussion'),
|
|
23
|
+
('moderate_comments', 'true', 'discussion')
|
|
24
|
+
`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const down = async (db, grammar) => {
|
|
28
|
+
await db.exec(grammar.dropTable('settings'))
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add roles to users.
|
|
3
|
+
*
|
|
4
|
+
* Before this, every authenticated user could reach the whole admin area —
|
|
5
|
+
* `auth: true` was the only gate. New accounts now default to the least
|
|
6
|
+
* privileged role.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const up = async (db) => {
|
|
10
|
+
await db.exec(`
|
|
11
|
+
ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'subscriber'
|
|
12
|
+
`)
|
|
13
|
+
|
|
14
|
+
// The first account is whoever set the site up, so it keeps full access.
|
|
15
|
+
await db.exec(`
|
|
16
|
+
UPDATE users SET role = 'admin'
|
|
17
|
+
WHERE id = (SELECT MIN(id) FROM users)
|
|
18
|
+
`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const down = async (db) => {
|
|
22
|
+
await db.exec('ALTER TABLE users DROP COLUMN role')
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-lived credentials: email verification, password reset, and anything
|
|
3
|
+
* else handed out as an opaque string with an expiry.
|
|
4
|
+
*
|
|
5
|
+
* Only a hash of the token is stored, so a copy of this table does not let
|
|
6
|
+
* anyone verify an address or reset a password.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const up = async (db, grammar) => {
|
|
10
|
+
await db.exec(`
|
|
11
|
+
CREATE TABLE auth_tokens (
|
|
12
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
13
|
+
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
14
|
+
kind TEXT NOT NULL,
|
|
15
|
+
token_hash TEXT NOT NULL,
|
|
16
|
+
metadata TEXT,
|
|
17
|
+
expires_at ${grammar.timestampType()} NOT NULL,
|
|
18
|
+
used_at ${grammar.timestampType()},
|
|
19
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
20
|
+
)
|
|
21
|
+
`)
|
|
22
|
+
|
|
23
|
+
// Redemption looks a token up by its hash on every request that carries one.
|
|
24
|
+
await db.exec('CREATE INDEX idx_auth_tokens_hash ON auth_tokens (token_hash, kind)')
|
|
25
|
+
await db.exec('CREATE INDEX idx_auth_tokens_user ON auth_tokens (user_id, kind)')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const down = async (db, grammar) => {
|
|
29
|
+
await db.exec(grammar.dropTable('auth_tokens'))
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mark whether a user has confirmed their email address.
|
|
3
|
+
*
|
|
4
|
+
* Existing rows are backfilled as verified. They predate the feature, and
|
|
5
|
+
* retroactively locking out everyone who already had an account would be a
|
|
6
|
+
* strange way to introduce it.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const up = async (db, grammar) => {
|
|
10
|
+
await db.exec(`
|
|
11
|
+
ALTER TABLE users ADD COLUMN email_verified INTEGER NOT NULL DEFAULT 0
|
|
12
|
+
`)
|
|
13
|
+
await db.exec(`ALTER TABLE users ADD COLUMN email_verified_at ${grammar.timestampType()}`)
|
|
14
|
+
|
|
15
|
+
await db.exec(`
|
|
16
|
+
UPDATE users
|
|
17
|
+
SET email_verified = 1, email_verified_at = CURRENT_TIMESTAMP
|
|
18
|
+
`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const down = async (db) => {
|
|
22
|
+
await db.exec('ALTER TABLE users DROP COLUMN email_verified')
|
|
23
|
+
await db.exec('ALTER TABLE users DROP COLUMN email_verified_at')
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Second-factor enrolment, one row per user.
|
|
3
|
+
*
|
|
4
|
+
* The TOTP secret is stored encrypted, so a copy of this table is not a set of
|
|
5
|
+
* working second factors. Because the key is derived from APP_KEY, rotating it
|
|
6
|
+
* invalidates every enrolled secret and users must re-enrol.
|
|
7
|
+
*
|
|
8
|
+
* totp_last_step is the replay guard: a code stays valid for its whole
|
|
9
|
+
* 30-second window, so the accepted step has to be remembered or an intercepted
|
|
10
|
+
* code can be used again inside it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const up = async (db, grammar) => {
|
|
14
|
+
await db.exec(`
|
|
15
|
+
CREATE TABLE user_two_factor (
|
|
16
|
+
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
|
17
|
+
totp_secret TEXT,
|
|
18
|
+
totp_enabled_at ${grammar.timestampType()},
|
|
19
|
+
totp_last_step INTEGER,
|
|
20
|
+
recovery_codes TEXT,
|
|
21
|
+
failed_attempts INTEGER NOT NULL DEFAULT 0,
|
|
22
|
+
locked_until ${grammar.timestampType()},
|
|
23
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
24
|
+
)
|
|
25
|
+
`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const down = async (db, grammar) => {
|
|
29
|
+
await db.exec(grammar.dropTable('user_two_factor'))
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkeys. Many per user, unlike TOTP.
|
|
3
|
+
*
|
|
4
|
+
* The public key is exactly that — public — so it needs no encryption. What
|
|
5
|
+
* matters is that credential_id is unique: it is the handle an authenticator
|
|
6
|
+
* presents, and two users sharing one would make authentication ambiguous.
|
|
7
|
+
*
|
|
8
|
+
* sign_count detects a cloned authenticator, but many passkeys always report
|
|
9
|
+
* zero, so zero means "not supported" rather than "suspicious".
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const up = async (db, grammar) => {
|
|
13
|
+
await db.exec(`
|
|
14
|
+
CREATE TABLE user_credentials (
|
|
15
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
16
|
+
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
17
|
+
credential_id TEXT NOT NULL UNIQUE,
|
|
18
|
+
public_key TEXT NOT NULL,
|
|
19
|
+
algorithm INTEGER NOT NULL,
|
|
20
|
+
sign_count INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
transports TEXT,
|
|
22
|
+
label TEXT,
|
|
23
|
+
backed_up INTEGER NOT NULL DEFAULT 0,
|
|
24
|
+
last_used_at ${grammar.timestampType()},
|
|
25
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
26
|
+
)
|
|
27
|
+
`)
|
|
28
|
+
|
|
29
|
+
// Sign-in looks a credential up by the id the authenticator presents.
|
|
30
|
+
await db.exec('CREATE INDEX idx_user_credentials_user ON user_credentials (user_id)')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const down = async (db, grammar) => {
|
|
34
|
+
await db.exec(grammar.dropTable('user_credentials'))
|
|
35
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiter state.
|
|
3
|
+
*
|
|
4
|
+
* In the database rather than in memory because these limits are a security
|
|
5
|
+
* control: a lockout that a restart clears, or that a second instance cannot
|
|
6
|
+
* see, is not a lockout. The memory store is the right default for smoothing
|
|
7
|
+
* ordinary traffic, and the wrong one for this.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const up = async (db) => {
|
|
11
|
+
// BIGINT, not INTEGER: these columns hold `Date.now()`, and a millisecond
|
|
12
|
+
// epoch passed 2^31 in 2001. SQLite's INTEGER is 64-bit so it never noticed;
|
|
13
|
+
// Postgres refused the first write with "value out of range for type
|
|
14
|
+
// integer", which failed every login and registration behind the limiter.
|
|
15
|
+
// BIGINT reads as INTEGER affinity on SQLite, so one spelling serves both.
|
|
16
|
+
await db.exec(`
|
|
17
|
+
CREATE TABLE rate_limits (
|
|
18
|
+
key TEXT PRIMARY KEY,
|
|
19
|
+
hits TEXT NOT NULL,
|
|
20
|
+
blocked_until BIGINT,
|
|
21
|
+
updated_at BIGINT NOT NULL
|
|
22
|
+
)
|
|
23
|
+
`)
|
|
24
|
+
|
|
25
|
+
// Sweeping deletes by age, so the scan wants an index.
|
|
26
|
+
await db.exec('CREATE INDEX idx_rate_limits_updated ON rate_limits (updated_at)')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const down = async (db, grammar) => {
|
|
30
|
+
await db.exec(grammar.dropTable('rate_limits'))
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store rendered HTML alongside the Markdown source.
|
|
3
|
+
*
|
|
4
|
+
* `content` stays canonical and holds the Markdown. `content_html` is a cache:
|
|
5
|
+
* it is rebuilt from `content` on every save and can be regenerated at any time
|
|
6
|
+
* with `basicben content:rerender`. Nothing should ever write to it directly.
|
|
7
|
+
*
|
|
8
|
+
* Rendering at save time rather than at request time is the cheaper trade for a
|
|
9
|
+
* blog, which is read far more often than it is written.
|
|
10
|
+
*
|
|
11
|
+
* Existing rows are backfilled through the same pipeline. Until this migration
|
|
12
|
+
* runs, post content was rendered as raw unsanitized HTML, so the backfill is
|
|
13
|
+
* also the point at which anything already stored stops being trusted.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { renderContent } from '@basicbenframework/core/content'
|
|
17
|
+
|
|
18
|
+
export const up = async (db) => {
|
|
19
|
+
await db.exec('ALTER TABLE posts ADD COLUMN content_html TEXT')
|
|
20
|
+
await db.exec('ALTER TABLE pages ADD COLUMN content_html TEXT')
|
|
21
|
+
|
|
22
|
+
for (const table of ['posts', 'pages']) {
|
|
23
|
+
const rows = await db.all(`SELECT id, content FROM ${table}`)
|
|
24
|
+
|
|
25
|
+
for (const row of rows) {
|
|
26
|
+
const html = await renderContent(row.content || '', {
|
|
27
|
+
context: { table, id: row.id, migration: true }
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
await db.run(`UPDATE ${table} SET content_html = ? WHERE id = ?`, [html, row.id])
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const down = async (db) => {
|
|
36
|
+
await db.exec('ALTER TABLE posts DROP COLUMN content_html')
|
|
37
|
+
await db.exec('ALTER TABLE pages DROP COLUMN content_html')
|
|
38
|
+
}
|